﻿package dt 
{
	import dt.exchangeddata.BetInfo;
	import dt.exchangeddata.UserLiveBetPoolInfo;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import game.events.EventData;
	import game.exchangeddata.HashTable;
	/**
	 * ...
	 * @author Nguyen Thi Bich Phuong (Daisy)
	 */
	public class UserLiveBetPoolPanel extends MovieClip {
		public var movPrivate:MovieClip;
		public var movPublic:MovieClip;
		
		public var txtPublicTf:TextField;
		public var txtPrivateTf:TextField;
		
		public var btnPublic:SimpleButton
		public var btnPrivate:SimpleButton;
		
		public var txtDragonTf:TextField;
		public var txtTigerTf:TextField;
		public var txtTieTf:TextField;		
		
		public var statisticDragonTf:TextField;
		public var statisticTigerTf:TextField;
		public var statisticTieTf:TextField;
		
		
		public var isPublic:Boolean = false;
		
		/**
		 * @author Daisy
		 */
		public function UserLiveBetPoolPanel() { 		
			this.tabPublicActive(this.isPublic);
			
			this.btnPrivate.addEventListener(MouseEvent.CLICK, btnPrivateHandler);
			this.btnPublic.addEventListener(MouseEvent.CLICK, btnPublicHandler);
		}
		
		/**
		 * @author Daisy
		 * @param	e
		 */
		private function btnPrivateHandler(e:MouseEvent):void {
			this.isPublic = false;
			this.tabPublicActive(this.isPublic);
			
			dispatchEvent(new Event(EventData.UPDATE_LIVEBETPOOL_USER_PRIVATE, true));
		}
		
		/**
		 * @author Daisy
		 * @param	e
		 */
		private function btnPublicHandler(e:MouseEvent):void {
			this.isPublic = true;
			this.tabPublicActive(this.isPublic);
			dispatchEvent(new Event(EventData.UPDATE_LIVEBETPOOL_USER_PUBLIC, true));
		}	
		
		/**
		 * @author Daisy
		 * @param	isActive
		 */
		private function tabPublicActive(isActive:Boolean) {
			if (isActive) {
				this.movPublic.gotoAndStop("invisible");
				this.txtPublicTf.textColor = 0xFFFFFF;
				this.movPrivate.gotoAndStop("visible");
				this.txtPrivateTf.textColor = 0x666666;
			}else {
				this.movPrivate.gotoAndStop("invisible");
				this.txtPrivateTf.textColor = 0xFFFFFF;
				this.movPublic.gotoAndStop("visible");
				this.txtPublicTf.textColor = 0x666666;
			}
		}
		
		/**
		 * @author Daisy
		 * @param	liveBetPoolUserPrivate
		 */
		public function updateLiveBetPoolUserPrivate(betInfo:BetInfo) {
			this.statisticDragonTf.text = betInfo.arrBettingValue[0] + "";
			this.statisticTigerTf.text = betInfo.arrBettingValue[1] + "";
			this.statisticTieTf.text = betInfo.arrBettingValue[2] + "";		
		}
		
		/**
		 * @author Daisy
		 * @param	liveBetPoolUser
		 * @usage update data for live bet pool user public
		 */
		public function updateLiveBetPoolUserPublic(liveBetPoolUser:UserLiveBetPoolInfo) {
			this.statisticDragonTf.text = liveBetPoolUser.numDragon + "";
			this.statisticTigerTf.text = liveBetPoolUser.numTiger + "";
			this.statisticTieTf.text = liveBetPoolUser.numTie + "";			
		}
		
		/**
		 * @author	Bamboo
		 */
		public function initLivebetPoolUser():void {
			statisticDragonTf.text = "0";
			statisticTigerTf.text = "0";
			statisticTieTf.text = "0";			
		}
		
		public function initText(hashTableInfo:HashTable):void {
			this.txtDragonTf.text = hashTableInfo.lookupString("Pooldragon") + ":";
			this.txtTigerTf.text = hashTableInfo.lookupString("Pooltiger") + ":";
			this.txtTieTf.text = hashTableInfo.lookupString("Pooltie") + ":";			
			this.txtPublicTf.text = hashTableInfo.lookupString("public");
			this.txtPrivateTf.text = hashTableInfo.lookupString("private");
		}
	}
}